<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<script src="../js/mui.min.js"></script>
		<script type="text/javascript">
			mui.init();
			mui.plusReady(function() {

				mui('#camera')[0].addEventListener('tap', function(event) {
					var btnArray = [{
						title: "拍照"
					}, {
						title: "从相册选择"
					}];
					plus.nativeUI.actionSheet({
						title: "选择照片",
						cancel: "取消",
						buttons: btnArray
					}, function(e) {
						var index = e.index;
						switch(index) {
							case 0:
								break;
							case 1:
								var cmr = plus.camera.getCamera();
								cmr.captureImage(function(path) {
									handlePictureResult({
										sender: 'self',
										type: 'image',
										content: "file://" + plus.io.convertLocalFileSystemURL(path)
									});
								}, function(err) {});
								break;
							case 2:
								plus.gallery.pick(function(path) {
									handlePictureResult({
										sender: 'self',
										type: 'image',
										content: path
									});
								}, function(err) {}, null);
								break;
						}
					});
				}, false);

				//处理图片的结果
				function handlePictureResult(resultObj) {
					//alert(resultObj.content);
					document.querySelector('#img').src=resultObj.content;
				};

			});
		</script>
	</head>

	<body bgcolor="#FFFFFF">

		<!--
	http://image.baidu.com/search/down?tn=download&word=download&ie=utf8&fr=detail&url=http%3A%2F%2Ff.hiphotos.baidu.com%2Fzhidao%2Fpic%2Fitem%2Fb999a9014c086e06e0aa15ef01087bf40ad1cb10.jpg&thumburl=http%3A%2F%2Fimg0.imgtn.bdimg.com%2Fit%2Fu%3D4167131107%2C3436954641%26fm%3D26%26gp%3D0.jpg
-->
		<div class="mui-content" align="center" style="margin-top: 100px;">
			<i id='camera' class="mui-icon mui-icon-camera" style="font-size: 58px;background:#D3D3D3;"></i>
			<img id="img" src="" style="display: block;margin-top: 10px;height: 350px;" />
		</div>

	</body>

</html>